package cn.edu.xmu.javaee.productdemoaop.repository.entity;

import cn.edu.xmu.javaee.productdemoaop.mapper.generator.po.OnSalePo;
import cn.edu.xmu.javaee.productdemoaop.mapper.generator.po.ProductPo;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;


@Entity
@Getter
@Setter
@Table(name = "goods_product")
public class Productjpa {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "goods_id")
    private Long goodsId;

    @Transient
    private List<Productjpa> otherProducts = new ArrayList<>();

    // 与 OnSalejpa 的关联，一个产品对应多个上架信息
    @OneToMany(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OnSalejpa> onSaleList = new ArrayList<>();

    @Column(name = "sku_sn")
    private String skuSn;

    @Column(name = "name")
    private String name;

    @Column(name = "original_price")
    private Long originalPrice;

    @Column(name = "weight")
    private Long weight;

    @Column(name = "barcode")
    private String barcode;

    @Column(name = "unit")
    private String unit;

    @Column(name = "origin_place")
    private String originPlace;

    @Column(name = "creator_id")
    private Long creatorId;

    @Column(name = "creator_name")
    private String creatorName;

    @Column(name = "modifier_id")
    private Long modifierId;

    @Column(name = "modifier_name")
    private String modifierName;

    @Column(name = "gmt_create")
    private LocalDateTime gmtCreate;

    @Column(name = "gmt_modified")
    private LocalDateTime gmtModified;

    @Column(name = "commission_ratio")
    private Integer commissionRatio;

    @Column(name = "free_threshold")
    private Long freeThreshold;

    @Column(name = "status")
    private Byte status;

    @Column(name = "product_id")
    private Long productId;
}
